<?php
/*
 * Gallery - a web based photo album viewer and editor
 * Copyright (C) 2000-2002 Bharat Mediratta
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
?>
<?php
// Hack prevention.
if (!empty($_REQUEST["GALLERY_BASEDIR"])) {
	print "Security violation\n";
	exit;
}
?>
<?php require("./init.php"); ?>
<?php
// Hack check
if (!$gallery->user->canWriteToAlbum($gallery->album)) {
	exit;
}
?>
<html>
<head>
<title><?php echo _XG_SORT_ALBUM;?></title>
<?php echo getStyleSheetLink() ?>
</head>
<body>

<?php
if ($gallery->session->albumName) {
	if (isset($confirm)) {
		if (!strcmp($sort,"random")) {
			$gallery->album->shufflePhotos();
			$gallery->album->save();
			dismissAndReload();
			return;
		} else {
			$gallery->album->sortPhotos($sort,$order,true);
			$gallery->album->save();
			dismissAndReload();
			return;
		}
	} else {
?>
<center><?php echo _XG_SORTORDER;?><br><?php echo _XG_SORTNOREGRET;?><br><br><p>
<?php
if ($gallery->album->getHighlight()) {
	print $gallery->album->getThumbnailTag($gallery->album->getHighlight());
}
?>
<br>
<?php echo @$gallery->album->fields["caption"] ?>

<?php echo makeFormIntro("sort_album.php"); ?>
<table>
<tr><td><input checked type="radio" name="sort" value="upload">&nbsp;<?php echo _XG_SORTBYUPLOADD;?></td></tr>
<tr><td><input type="radio" name="sort" value="itemCapture">&nbsp;<?php echo _XG_SORTBYSNAPSHO;?></td></tr>
<tr><td><input type="radio" name="sort" value="filename">&nbsp;<?php echo _XG_SORTBYFILENAM;?></td></tr>
<tr><td><input type="radio" name="sort" value="click">&nbsp;<?php echo _XG_SORTBYCLICKSA;?></td></tr>
<tr><td><input type="radio" name="sort" value="caption">&nbsp;<?php echo _XG_SORTBYCAPTION;?></td></tr>
<tr><td><input type="radio" name="sort" value="comment">&nbsp;<?php echo _XG_SORTBYCOMMENT;?></td></tr>
<tr><td><input type="radio" name="sort" value="random">&nbsp;<?php echo _XG_SORTBYRANDOMS;?></td></tr>
<tr><td align="center"><select name="order">
<option value="0"><?php echo _XG_SORTASCE;?></option><option value="1"><?php echo _XG_SORTDESC;?></option></select>
</td></tr></table><br>
<input type="submit" name="confirm" value="<?php echo _XG_GOSORT;?>">
<input type="submit" value="<?php echo _XG_CANCEL;?>" onclick='parent.close()'>
</form>
<?php
	}
} else {
	gallery_error("no album specified");
}
?>

</body>
</html>
